package com.zijie.category.model;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;

import com.zijie.core.util.AuditEntity;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

@Getter
@Setter
@TableName("category")
public class Category extends AuditEntity {
    @TableId(type = IdType.AUTO)
    private Integer id;
    private Integer parentId;
    @TableField(condition = SqlCondition.LIKE,whereStrategy = FieldStrategy.NOT_NULL)
    private String name;
    private String icon;
    //排序号
    private Integer sort;
    //父分类
    @TableField(exist = false)
    @JsonBackReference//告诉json序列化器，这个字段不需要被序列化
    private Category parent;
    //子分类
    @TableField(exist = false)
    @JsonManagedReference//告诉json序列化器，这个字段需要被序列化
    private List<Category> children;
}
